package com.teama4.shop.service;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.teama4.shop.domain.*;
import com.teama4.shop.mapper.EvaluateMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class EvaluateServiceImpl implements EvaluateService {
    @Autowired
    private EvaluateMapper evaluateMapper;

    @Override
    public long countByExample(EvaluateExample example) {
        return evaluateMapper.countByExample(example);
    }

    @Override
    public int deleteByExample(EvaluateExample example) {
        return evaluateMapper.deleteByExample(example);
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return evaluateMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(Evaluate record) {
        return evaluateMapper.insert(record);
    }

    @Override
    public int insertSelective(Evaluate record) {
        return evaluateMapper.insertSelective(record);
    }

    @Override
    public List<Evaluate> selectByExample(EvaluateExample example) {
        return evaluateMapper.selectByExample(example);
    }

    @Override
    public Evaluate selectByPrimaryKey(Integer id) {
        return evaluateMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByExampleSelective(Evaluate record, EvaluateExample example) {
        return evaluateMapper.updateByExampleSelective(record, example);
    }

    @Override
    public int updateByExample(Evaluate record, EvaluateExample example) {
        return evaluateMapper.updateByExample(record, example);
    }

    @Override
    public int updateByPrimaryKeySelective(Evaluate record) {
        return evaluateMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(Evaluate record) {
        return evaluateMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<EvaluateUserSpeComExt> selectAllEvaluateByUserId(Integer userId) {
        return evaluateMapper.selectAllEvaluateByUserId(userId);
    }

    @Override
    public EvaluateUserSpeComExtPaging selectAllEvaluateByUserIdPaging(Integer userId, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<EvaluateUserSpeComExt> evaluateUserSpeComExts = evaluateMapper.selectAllEvaluateByUserId(userId);

        Long total = ((Page)evaluateUserSpeComExts).getTotal();
        return new EvaluateUserSpeComExtPaging(total,evaluateUserSpeComExts);
    }

    @Override
    public List<EvaluateUserSpeComExt> selectEvaluateByComId(Integer commodityId) {
        return evaluateMapper.selectEvaluateByComId(commodityId);
    }

    @Override
    public List<EvaluateUserSpeComExt> selectEvaluateBySpeId(Integer specificationId) {
        return evaluateMapper.selectEvaluateBySpeId(specificationId);
    }

    @Override
    public EvaluateUserSpeComExt selectEvaluateByUserSpeId(Integer userId, Integer orderId, Integer specificationId) {
        return evaluateMapper.selectEvaluateByUserSpeId(userId,orderId,specificationId);
    }



}
